package com.silence.ByteDance;

import java.util.Collection;
import java.util.HashSet;
import java.util.Map;

public class easy_28 {
    public static int solution(int[][] inputArray) {
        // Please write your code here
        Collection<Integer> collection = new HashSet<>();
        for (int i = 0; i < inputArray.length; i++) {
            for (int j = inputArray[i][0]; j <= inputArray[i][1]; j++) {
                collection.add(j);
            }
        }
        return collection.size();
    }

    public static void main(String[] args) {
        //  You can add more test cases here
        int[][] testArray1 = {{1, 4}, {7, 10}, {3, 5}};
        int[][] testArray2 = {{1, 2}, {6, 10}, {11, 15}};

        System.out.println(solution(testArray1) == 9);  // 7
        System.out.println(solution(testArray2) == 12); // 12
    }
}
